﻿using DataProj.Areas.BackSys.ServiceTools.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace DataProj.Areas.BackSys.ServiceTools
{
    public class RuntimeCache : ICache
    {
        readonly static System.Web.Caching.Cache httpRuntimeCache = System.Web.HttpRuntime.Cache;
        readonly static int _expireMinutes = 20;  //ConfigConstants.ConfigManager.Config.Cache_ExpireMinutes;配置默认多少秒过时
        public void Put(string key, object obj)
        {
            httpRuntimeCache.Insert(key, obj);
        }

        public void Put(string key, object obj, int expireMinutes)
        {
            httpRuntimeCache.Insert(key, obj, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(expireMinutes));
        }

        public object Get(string key)
        {
            return httpRuntimeCache.Get(key);
        }

        public void Delete(string key)
        {
            httpRuntimeCache.Remove(key);
        }
    }
}